import pygame

import settings as set
from ship import Ship
import game_funtions as gf


def run_game():
    """
    1. 创建屏幕
    2. 刷新屏幕重新绘制
    :return:
    """
    # ----------- 加载配置 -----------------
    ai_set = set.settings()
    pygame.init()
    # ----------- 创建屏幕 -------------------
    screen = pygame.display.set_mode((ai_set.screen_height, ai_set.screen_width))
    pygame.display.set_caption(ai_set.title)  # 屏幕标题
    # 创建飞船
    ship = Ship(settings=ai_set, screen=screen)
    while True:
        gf.check_events(ship=ship)
        ship.update()
        gf.update_screen(settings=ai_set, screen=screen, ship=ship)


if __name__ == '__main__':
    run_game()
